<!-- 双11抽奖页面 lottery -->
<div class="double-11-lottery">
	<div class="condition head">
		<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/1.png">
		<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/2.png">
		<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/3.png">
		<div class="down picdown1" style="z-index:12;"></div>
		<div class="down picdown2"></div>
		<div class="down picdown3"></div>
		<div class="down picdown4"></div>
	</div>

	<div style="width:1008px" class="condition content">
		<div class="zhongjiang">
			<div class="zhong"><span>中奖榜</span></div>
			<div class="zhongjiangming">
			<ul style="overflow:hidden" id="Marquee">

			</ul>
			</div>
		</div>
		<div class="lingjiang">
			<h1 style="text-align:center;color:#fff;">领奖时间：11月11日0点-11月17日24点</h1>
			<p style="text-align:center;color:yellow;margin:5px 0;">只限1折网注册会员, 每人一天只限领奖一次</p>
			<div class="turntable">
				<div class="disc"></div>
				<div class="pointer">
					<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/pointer.png" id="lotteryBtn" >
				</div>
			</div>
		</div>
	</div>
	<div style="" class="condition canyu"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/canyu.jpg"></div>

	<div class="condition introduce">
		<div class="loging-reg"></div>
		<a class="down-app-btn" href="<?php echo $this->createUrl('/front/download/app'); ?>" target="_blank"></a>
	</div>

	<div class="condition how-receive"></div>
	<div class="how-receive-btn"><a href="https://cshall.alipay.com/lab/help_detail.htm?help_id=211842" target="_blank">如何使用红包 > </a></div>
	
	<div class="footer" style="text-align:center">本活动最终解释权归1折网所有</div>
	<div class="condition">
		<?php include $this->getViewFile('//user/lib/login_and_reg'); ?>
	</div>
</div>

<div style="display:none" class="lottery-msg error-msg">
    <div style="border-radius:5px;">
    	<img style="border-radius:5px;" src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/error_img.png">
    </div>
    <div class="cntent">
    	<p class="msg_text_title">error</p>
    </div>
</div>

<div style="display:none" class="lottery-msg award-msg">
    <div style="border-radius:5px;">
    	<img style="border-radius:5px;" src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/front/double-11/lottery/award_img.png">
    </div>
    <div class="award_cntent">
    	<p class="msg_text_title">恭喜您抽中XXX元红包</p>
    	<p class="msg_text_1" style="display:none;"></p>
    	<p class="msg_text_2" style="display:none;"></p>
    	<p class="click"  style="display:none;" onclick="window.open('https://hongbao.alipay.com/coupon/getbyno.htm');">马上前往支付宝</p>
    </div>
</div>



<script src="<?php echo Yii::app()->params->staticUrl; ?>statics/js/ajaxForm.js"></script>
<script src="/themes/1zw/assets/js/lib/jQueryRotate.2.2.js"></script>
<script>
var pagetype = 's11';
var share_s11 = true;
//中奖名单滚动效果
var $Marquee = $(".zhongjiang");
var scrollTimer;
$Marquee.hover(function() {clearInterval(scrollTimer)},function() {
	scrollTimer = setInterval(function() {
		scrollNews($Marquee)
	},
	2000)
}).trigger("mouseout");
//自动滚动
function scrollNews(obj) {
	var $self = obj.find("ul:first");
	var lineHeight = $self.find("li:first").height();
	$self.animate({
		"margin-top": -lineHeight + "px"
	},
	600,
	function() {
		$self.css({
			"margin-top": "0px"
		}).find("li:first").appendTo($self)
	})
};

//自动下落图片
setInterval(function(){
	$(".picdown1").animate({top:"470px"},10000,function(){
	$(".picdown1").css({top:"-470px"});
	});
},0);
setTimeout(function(){
setInterval(function(){
	$(".picdown2").animate({top:"470px"},8000,function(){
	$(".picdown2").css({top:"-470px"});
	});	
},0)},5000);

setTimeout(function(){
setInterval(function(){
	$(".picdown3").animate({top:"470px"},6000,function(){
	$(".picdown3").css({top:"-470px"});
	});	
},0)},8000);

setTimeout(function(){
setInterval(function(){
	$(".picdown4").animate({top:"470px"},8000,function(){
	$(".picdown4").css({top:"-470px"});
	});	
},0)},10000);

//信息层
//恭喜您抽中500元红包<br>卡号:'+returndata.cardno+'<br>验证码:'+returndata.password
var errordiv = $(".error-msg");
var awarddiv = $(".award-msg");
$(function(){
	//超时or错误函数
	var timeOut = function(){
		$("#lotteryBtn").rotate({
			angle:0, 
			duration: 10000, 
			animateTo: 2160-20, //这里是设置请求超时后返回的角度，所以应该还是回到最原始的位置，2160是因为我要让它转6圈，就是360*6得来的
			callback:function(){
				var errormsg = dialog({
					quickClose:true,
		            width: 540,
		            padding: 0,
				    content: errordiv.show()
				});
				errormsg.show();
				$(".error-msg .msg_text_title").html('请求超时');
			}
		}); 
	};
	//错误返回
	var errorStatus = function(info){
		/*
			nostarttime	活动未开始
			yesendtime 	活动已经结束
			nophone 	没有绑定手机
			isparticipate 今天已经参加过
		*/
		if(info == 'nostarttime'){
			msg = '活动未开始！';
		}else if(info == 'yesendtime'){
			msg = '活动已经结束！';
		}else if(info == 'nophone'){
			msg = '没有绑定手机！';
		}else if(info == 'isparticipate'){
			msg = '今天已经参加过！';
		}else if(info == 'nologin'){
			msg = '登陆后再参与抽奖活动！';
		}
		//msg_text_title	登陆后才可以参与抽奖活动！
		var errormsg = dialog({
			quickClose:true,
            width: 540,
            padding: 0,
		    content: errordiv.show()
		});
		errormsg.show();
		$(".error-msg .msg_text_title").html(msg);
	};
	//awards:奖项，angle:奖项对应的角度
	var rotateFunc = function(awards,angle,text,cardno,password){
		//msg_text_title
		
		$('#lotteryBtn').stopRotate();
		$("#lotteryBtn").rotate({
			angle:0, 
			duration: 5000, 
			animateTo: angle+2160, //angle是图片上各奖项对应的角度，2160是我要让指针旋转360 * 6圈。
			callback:function(){
				var d = dialog({
					quickClose:true,
                    width: 540,
                    padding: 0,
				    content: awarddiv.show()
				});
				d.show();
				$(".msg_text_title").html(text);
				if(cardno != ''){
					$(".msg_text_1").html("卡&nbsp&nbsp&nbsp&nbsp号:"+cardno);
					$(".msg_text_1").show();
					$('.click').show();
				}
				if(password != ''){
					$(".msg_text_2").html("验证码:"+password);
					$(".msg_text_2").show();
				}
			}
		}); 
	};
	
	/*
	const iphone = 1; //苹果6
    const red500 = 2; //500红包
    const red200 = 3; //200红包
    const red100 = 4; //100红包
    const red60 = 5; //50红包
    const red30 = 6; //30红包
    const red5 = 7; //5红包
    
      160  200
	120      240
	80       280
	  40   360
	  	 0
    */
    //点击抽奖
	$("#lotteryBtn").rotate({ 
	   bind: 
		 { 
			click: function(){
//				var data = ['isparticipate','nostarttime','yesendtime','nophone']; //返回的数组
//				data = data[Math.floor(Math.random()*data.length)];
//				errorStatus(data);//nostarttime
				
				$.ajax({
			        url: "/front/lottery/draw.html?t=" + new Date().getTime(),
			        type: "GET",
			        timeout: 5000,
			        dataType: "json",
			        success: function(returndata) {
						//console.log(returndata);
						errorStatus('nostarttime');
						
			        },
				  	error:function(s,error){
			        	errorStatus('nostarttime');
					}
			    });
			    
				//ajax end
			}
		 } 
	   
	});

    $('.loging-reg').click(function(){
    	login(this);
    });
    // 登录验证 star
	function login(obj) {
          $('div.login_reg_page').show();
          $("#login-regmobile").append('<input  type="hidden" value="1" name="MembersModel[kind]" />');
          $('#login-form').ajaxForm({
              dataType: 'json',
              url: '<?php echo YzwController::U('user/bm/login') ?>',
              success: function(data) {
                  if (data.status) {
                      $('#login-form').clearForm();
                      $('div.login_reg_page').hide();
                      userid = true;
                      userkind = data.kind;
                      if (parseInt(userkind) == 0) {
                          var d = dialog({
                              title: '提示',
                              content: '亲，您的账户类型是“商家用户”，不能进行抽奖！',
                              cancel: false,
                              okValue: '确定',
                              ok: function() {
                              }
                          });
                          d.show();
                          return true;
                      }
                      exchange(obj);
                      //$('#goodsbm').submit();
                  } else {
                      var d = dialog({
                          title: '提示',
                          content: data.info,
                          cancel: false,
                          okValue: '确定',
                          ok: function() {
                          }
                      });
                      d.show();
                  }
              }
          });
          $('#login-regmobile').ajaxForm({
              dataType: 'json',
              success: function(data) {
                  if (data.status) {
                      $('#login-form').clearForm();
                      $('div.login_reg_page').hide();
                      //$('#goodsbm').submit();
                  } else {
                      var d = dialog({
                          title: '提示',
                          content: data.info,
                          cancel: false,
                          okValue: '确定',
                          ok: function() {
                          }
                      });
                      d.show();
                  }
              }
          });
    }
	//登录验证end
})


</script>